package com.lovely3x.loginandresgiter.login;

import android.support.annotation.NonNull;

import com.litesuits.orm.LiteOrm;
import com.lovely3x.common.consts.Const;
import com.lovely3x.common.managements.user.IUser;
import com.lovely3x.common.managements.user.IUserLander;
import com.lovely3x.common.requests.impl.HandlerRequestImpl;
import com.lovely3x.common.utils.ALog;

import java.util.ArrayList;
import java.util.List;

/**
 * 登陆器
 * Created by lovely3x on 16-4-15.
 */
public class SimpleLander extends HandlerRequestImpl implements IUserLander {

    private final LiteOrm mLiteOrm;

    public SimpleLander() {
        mLiteOrm = LiteOrm.newCascadeInstance(mContext, Const.DB_NAME);
    }

    @Override
    public int login(@NonNull IUser user) {
        return 0;
    }

    @Override
    public int logout(@NonNull IUser user) {
        return 0;
    }

    @NonNull
    @Override
    public List<IUser> getAllUserFromDatabases() {
        return new ArrayList<>();
    }

    @Override
    public IUser getLastUser() {
        return null;
    }

    @Override
    public void updateOrInsertUser(IUser user) {
        try {
            mLiteOrm.save(user);
        } catch (Exception e) {
            ALog.e(TAG, e);
        }
    }

    @Override
    public void cancelLogin() {

    }

    @Override
    public void cancelLogout() {

    }

    public LiteOrm getOrm() {
        return mLiteOrm;
    }
}
